package types

import (
	"cuelang.org/go/cue/ast"
	"fmt"
	"strings"
)

type List struct {
	vv *ast.ListLit
}

func (t *List) Value(ref bool) string {
	sType := t.vv.Elts[0].(*ast.Ellipsis).Type.(*ast.Ident).Name

	if strings.HasPrefix(sType, "#") {
		format := "[]%s"
		if ref {
			format = "[]*%s"
		}
		return fmt.Sprintf(format, strings.TrimPrefix(sType, "#"))
	}
	return fmt.Sprintf("[]%s", sType)
}
